Home | Printable Version
1.2.23: XML String
The XML String action is used to convert between XML formatted strings and actual XML data. This is often required during communication with web services that do not provide full XML data, but instead return a string containing the XML content. The mode parameter indicates the direction in which the conversion should take place. This can either be from a string into XML, or from an XML structure into a formatted string. The first mode is usually used on the response received from a remote service and the second mode before calling a remote service. The location parameter is used to indicate which section of the data the conversion should be applied to. If the String to XML mode is used, then the text content of the node selected by the location XPath will be converted into an XML structure. If the XML to String mode is used, then the node selected by the XPath will be replaced with it's string representation. Screen-shot of an example XML String action
Example
Assume you have called a web service that has returned the following content, which has been inserted into the Data section of the FactBase.
<ServiceResponse>
    <ServiceResult>&lt;record&gt;&lt;value1&gt;abc&lt;/value1&gt;&lt;value2&gt;123&lt;/value2&gt;&lt;/record&gt;</ServiceResult>
</ServiceResponse>
In this response the ServiceResult element actually contains an XML formatted string which we want to access. To do this, add an new XML String action after the Invoke Service action, and use a location XPath of /mvc:eForm/mvc:Data/ServiceResponse/ServiceResult and a mode of String to XML. This will convert the content in the FactBase to the following.
...
<ServiceResponse>
    <ServiceResult>
        <record>
            <value1>abc</value1>
            <value2>123</value2>
        </record>
    </ServiceResult></quote>
</ServiceResponse>
...
To convert this back to the initial String content you can set the location XPath to /mvc:eForm/mvc:Data/ServiceResponse/ServiceResult/record and use the XML to String mode value.
Validate RuleBase Settings